package com.sx.zongzhi.presenter;

import com.sx.zongzhi.MyApplication;
import com.sx.zongzhi.bean.PopulationDetailBean;
import com.sx.zongzhi.modle.CollectManager;
import com.sx.zongzhi.net.BaseCallBack;
import com.sx.zongzhi.net.BaseResult;
import com.sx.zongzhi.view.IPopHouseholdDetailView;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by XZY on 2017/11/30.
 *获取户籍人员列表
 */
public class PopHouseholdDetailPest {

    private IPopHouseholdDetailView detailView;

    public PopHouseholdDetailPest(IPopHouseholdDetailView detailView) {
        this.detailView=detailView;
    }


    /**
     *
     * @param id 户籍人口主键
     */
    public void getPopHouseholdDetail(String id){
        Map<String,Object> map=new HashMap<>();
        map.put("sid", MyApplication.sid);
        map.put("id", id);

        new CollectManager().getPopHouseholdDetail(map, new BaseCallBack<BaseResult<PopulationDetailBean>>() {
            @Override
            public void onSuccess(BaseResult<PopulationDetailBean> response) {
                detailView.getPopHouseholdDetail(response.getData());
            }
            @Override
            public void onFailures(String message) {
                detailView.showError(message);
            }
        });
    }

    /**
     *
     * @param id 户籍人口主键
     */
    public void deletePopHousehold(String id){
        Map<String,Object> map=new HashMap<>();
        map.put("sid", MyApplication.sid);
        map.put("id", id);

        new CollectManager().deletePopHousehold(map, new BaseCallBack<BaseResult<Boolean>>() {
            @Override
            public void onSuccess(BaseResult<Boolean> response) {
                detailView.deletePopHousehold(response.getData());
            }
            @Override
            public void onFailures(String message) {
                detailView.showError(message);
            }
        });
    }

}
